<template>
  <div class="lq-pay-confirm-container">
    <m-header title="确认选择">
      <img class="header-right" slot="right" src="../../../assets/imgs/live/schedule@2x.png" alt>
    </m-header>
    <div class="content">
      <div class="title">
        <div class="type">投注彩种：{{params.title}}</div>
        <div class="divider">|</div>
        <div class="schema">方案金额：{{params.money}}元</div>
      </div>
      <div class="comp">
        <div class="safe-comp">
          <div class="safe-comp-each">
            <div class="label">保密设置</div>
            <div class="tag">
              <div
                :key="index"
                @click.stop="params.secrecy_level=item.value"
                v-for="(item, index) in safeList"
                :class="item.value===params.secrecy_level?'active':''"
              >{{item.label}}</div>
            </div>
          </div>
          <div class="safe-comp-each">
            <div class="label">方案宣言</div>
            <div class="tag">
              <input v-model="params.desc" placeholder="最多可输入50个字">
            </div>
          </div>
        </div>
        <div class="allow">
          <check-icon :value.sync="params.is_allow_bill"></check-icon>允许他人跟单（佣金10%，发单人所得10%）
        </div>
        <div class="start-money">
          起跟金额
          <x-number v-model="params.min_price" :min="0"></x-number>
          <!-- <input type="checkbox" style="margin-right: 0.1rem"> 我要推广 -->
        </div>
        <div class="beishu">
          <div class="beishu1">
            <check-icon :value.sync="params.is_security_ratio"></check-icon>
            保障赔率
          </div>
          <div class="beishu2">
            <x-number v-model="params.security_ratio" :step="0.1" :min="1.3"></x-number>
          </div>
        </div>
        <div class="tip">（中奖赔率小于该赔率，不收取佣金）</div>
      </div>
    </div>
    <div class="bottom">
      <div class="button-wrapper">
        <div class="btn" @click="goBuy">确认支付</div>
      </div>
    </div>
  </div>
</template>
<script>
import { mapActions } from 'vuex';
import { XNumber, CheckIcon } from 'vux';
export default {
  components: {
    XNumber,
    CheckIcon
  },
  data () {
    return {
      params: {},
      checked: false,
      safeList: [
        {
          value: 1,
          label: '公开'
        },
        {
          value: 2,
          label: '保密'
        },
        {
          value: 3,
          label: '赛后公布'
        }
      ]
    };
  },
  created () {
    const { matchParams = {} } = this.$route.params || {};
    this.params = matchParams;
  },
  methods: {
    ...mapActions({
      goBetLq: 'match/goBetLq'
    }),
    goBuy () {
      const body = { ...this.params };
      body.is_security_ratio = body.is_security_ratio ? 1 : 0;
      body.is_allow_bill = body.is_allow_bill ? 1 : 0;
      this.goBetLq(body).then(res => {
        if (res) {
          this.$vux.toast.text('发单成功');
          this.$router.push({
            name: 'PayConfirm'
          });
        }
      });
    }
  }
};
</script>
<style lang="less">
.lq-pay-confirm-container {
  padding-top: 0.92rem;
  padding-bottom: 0.2rem;
  // background: #ffffff;
  height: 100%;
  .header-right {
    height: 0.4rem;
  }
  .header {
    height: 1rem;
    line-height: 1rem;
    text-align: center;
    color: #333333;
    font-size: 0.28rem;
    img {
      width: 0.8rem;
      margin-right: 0.2rem;
    }
  }
  .content {
    background: #ffffff;
    .title {
      height: 0.85rem;
      line-height: 0.85rem;
      text-align: center;
      color: #333333;
      font-size: 0.28rem;
      border-bottom: 1px solid #d2d2d2;
      .type {
        display: inline-block;
        // width: 3.4rem;
      }
      .divider {
        display: inline-block;
        width: 0.5rem;
        color: #d2d2d2;
      }
      .schema {
        display: inline-block;
        // width: 3.4rem;
      }
    }
    .comp {
      padding: 0.4rem 0.3rem;
      input[type="checkbox"] {
        width: 0.28rem;
        height: 0.28rem;
        background-color: #fff;
        -webkit-appearance: none;
        border: 0.01rem solid #c9c9c9;
        border-radius: 0.02rem;
        outline: none;
        &.active {
          background-color: #d44743;
        }
      }
      .safe-comp {
        .safe-comp-each {
          margin-bottom: 0.3rem;
          .label {
            display: inline-block;
            width: 1.2rem;
          }
          .tag {
            display: inline-block;
            text-align: center;
            div {
              display: inline-block;
              color: #747474;
              font-size: 0.26rem;
              width: 1.8rem;
              padding: 0.12rem 0;
              border-top: 1px solid #d2d2d2;
              border-bottom: 1px solid #d2d2d2;
              border-left: 1px solid #d2d2d2;
              height: 0.4rem;
              line-height: 0.4rem;
              &.active {
                background: #d44743;
                color: #ffffff;
              }
              &:nth-child(1) {
                border-top-left-radius: 0.1rem;
                border-bottom-left-radius: 0.1rem;
              }
              &:nth-child(3) {
                border-right: 1px solid #d2d2d2;
                border-top-right-radius: 0.1rem;
                border-bottom-right-radius: 0.1rem;
              }
            }
            input {
              border: 1px solid #d2d2d2;
              padding: 0.1rem 0.2rem;
              width: 5.04rem;
              &::-webkit-input-placeholder {
                color: #999999;
                font-size: 0.22rem;
              }
            }
          }
        }
      }
      // .allow {
      // }
      .start-money {
        display: flex;
        align-items: center;
      }
      .beishu {
        display: flex;
        align-items: center;
        margin-top: 0.1rem;
        .beishu1 {
          width: 2rem;
        }
        .beishu2 {
          width: 3.2rem;
        }
      }
      .tip {
          // width: 1.2rem;
          font-size: 0.2rem;
          color: #999999;
      }
    }
  }
  .bottom {
    text-align: center;
    .button-wrapper {
      margin-top: 0.6rem;
      margin-bottom: 0.44rem;
      padding: 0 0.26rem;
      .btn {
        text-align: center;
        height: 1rem;
        line-height: 1rem;
        font-size: 0.34rem;
        color: #ffffff;
        background: #d44743;
        cursor: pointer;
        border-radius: 0.06rem;
      }
    }
  }
}
</style>
